<?php 

class Accounts extends Zend_Db_Table_Abstract
{
	protected $_name = 'users';
	protected $_role = array('member', 'admin');

	
	private function setVars()
	{
		$registry = Zend_Registry::getInstance();
		
        if (null !== $registry->config->accounts->TableName) {
            $this->_name = $registry->config->accounts->TableName;
        }
		
        if (null !== $registry->config->accounts->IdentityColumn) {
            $this->_identityColumn = $registry->config->accounts->IdentityColumn;
        }
		
        if (null !== $registry->config->accounts->CredentialColumn) {
            $this->_credentialColumn = $registry->config->accounts->CredentialColumn;
        }
		
        if (null !== $registry->config->accounts->CredentialTreatment) {
            $this->_credentialTreatment = $registry->config->accounts->CredentialTreatment;
        }
		
	}

	/**
	 * @note	get row
	 * @info	
	 * @author	Dennis T. Kaplan
	 * @access	public
	 * @param	 
	 * @return	
	 */	
	public function getAlias($alias)
	{
		return parent::fetchRow(parent::select()->where('username = ?', $alias));
	}
	
	public function insert(array $data)
	{
		if(empty($data['created_on'])) {
			$data['created'] = time();
		}
		return parent::insert($data);
	}


}


class People extends Zend_Db_Table_Abstract
{
	protected $_name = 'people';
	protected $_referenceMap = array(
			'Account' => array(
			'columns'        => array('id'),
			'refTableClass' => 'Accounts',
			'refColumns' => 'id'
			));
	
	public function insert(array $data)
	{
		if(empty($data['created_on'])) {
			$data['created'] = time();
		}
		return parent::insert($data);
	}
	
}

class Company extends Zend_Db_Table_Abstract
{
	protected $_name = 'accounts';
}

?>
